package com.organization

import grails.test.*

class DepartmentTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testConstraints() {
        def dep1 = new Department(name: "Dep1")
        mockForConstraintsTests(Department, [ dep1 ])

        def testDep = new Department()
        assertFalse testDep.validate()
        assertEquals "nullable", testDep.errors["name"]

        testDep = new Department(name: "Dep1")
        assertFalse testDep.validate()
        assertEquals "unique", testDep.errors["name"]

        testDep = new Department(name: "D")
        assertFalse testDep.validate()
        assertEquals "size", testDep.errors["name"]

        testDep = new Department(name: "Dep2")
        assertTrue testDep.validate()
    }
}
